import axios from 'axios';

const request = axios.create({
  timeout: 60000, // 请求超时时间
  responseType: 'json'
  // withCredentials: true
})

function scan(params){
  return request({
    url: '/nuc/scan',
    method: 'post',
    headers: {'Content-Type': 'application/json'},
    data:{
      "taskId": params['taskId'],
      "project": '',
      "building": '',
      "suite": params['suite'],
      "room": params['room'],
      "stage": ''
    }
  })
}

function queryState(id){
  return request({
    url: '/nuc/queryState',
    method: 'post',
    headers: {'Content-Type': 'application/json'},
    data: {
      "taskId": id
    }
  })
}

function queryAllFinishedTasks(){
  return request({
    url: '/nuc/queryAllFinishedTasks',
    method: 'post',
  })
}

function queryDevicePowerAndSPace(){
  return request({
    url: '/nuc/queryDevicePowerAndSPace',
    method: 'post',
  })
}


function deleteTask(id){
  return request({
    url: '/nuc/deleteByTasks',
    method: 'post',
    headers: {'Content-Type': 'application/json'},
    data: {
      "taskIds": id
    }
  })
}

function submitRules(id){
  return request({
    url: '/nuc/submitRules',
    method: 'post',
    headers: {'Content-Type': 'application/json'},
    data: {
      "taskId": id,
       "rules": "{\"standards\":[{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"顶板总面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"53\",\"unit\":\"m²\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"墙面尺寸\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"56\",\"unit\":\"mm\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"墙面总面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"52\",\"unit\":\"m²\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"墙面面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"51\",\"unit\":\"m²\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"地板总面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":null,\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"方正度\",\"quality_algorithm\":\"Range\",\"mapped_sdk_item_id\":\"10\",\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"房间开间进深偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"21\",\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"阴阳角方正\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"7\",\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"室内净高偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"6\",\"unit\":\"mm\"},{\"min_value\":\"0\",\"max_value\":\"10\",\"conditions\":\"[0,10]\",\"measurement_item_name\":\"水平度极差\",\"quality_algorithm\":\"Range\",\"mapped_sdk_item_id\":\"4\",\"unit\":\"mm\"},{\"min_value\":\"0\",\"max_value\":\"5\",\"conditions\":\"[0,5]\",\"measurement_item_name\":\"垂直度\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"3\",\"unit\":\"mm\"},{\"min_value\":\"0\",\"max_value\":\"8\",\"conditions\":\"[0,8]\",\"measurement_item_name\":\"平整度\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"2\",\"unit\":\"mm\"},{\"min_value2\":\"-5\",\"max_value2\":\"11\",\"conditions2\":\"[-5,11]\",\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"外门窗洞口尺寸宽度偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"5\",\"unit\":\"mm\"},{\"min_value2\":\"-5\",\"max_value2\":\"5\",\"conditions2\":\"[-5,5]\",\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"户内门洞尺寸宽度偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"11\",\"unit\":\"mm\"}],\"designs\":[{\"standard_value2\":\"5000\",\"standard_value\":\"3510\",\"name\":\"开间进深尺寸\",\"mapped_sdk_item_id\":\"21\"},{\"standard_value2\":\"1500\",\"standard_value\":\"880\",\"name\":\"门尺寸\",\"mapped_sdk_item_id\":\"11\"},{\"standard_value2\":\"800\",\"standard_value\":\"880\",\"name\":\"窗尺寸\",\"mapped_sdk_item_id\":\"5\"},{\"standard_value\":\"2810\",\"name\":\"净高\",\"mapped_sdk_item_id\":\"6\"}]}"
    }
  })
}

function submitDesign(parm){
  return request({
    url: '/nuc/submitRules',
    method: 'post',
    headers: {'Content-Type': 'application/json'},
    data: {
      "taskId": id,
       "rules": "{\"standards\":[{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"顶板总面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"53\",\"unit\":\"m²\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"墙面尺寸\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"56\",\"unit\":\"mm\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"墙面总面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"52\",\"unit\":\"m²\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"墙面面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"51\",\"unit\":\"m²\"},{\"min_value\":\"*\",\"max_value\":\"*\",\"conditions\":\"*\",\"measurement_item_name\":\"地板总面积\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":null,\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"方正度\",\"quality_algorithm\":\"Range\",\"mapped_sdk_item_id\":\"10\",\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"房间开间进深偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"21\",\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"阴阳角方正\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"7\",\"unit\":\"mm\"},{\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"室内净高偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"6\",\"unit\":\"mm\"},{\"min_value\":\"0\",\"max_value\":\"10\",\"conditions\":\"[0,10]\",\"measurement_item_name\":\"水平度极差\",\"quality_algorithm\":\"Range\",\"mapped_sdk_item_id\":\"4\",\"unit\":\"mm\"},{\"min_value\":\"0\",\"max_value\":\"5\",\"conditions\":\"[0,5]\",\"measurement_item_name\":\"垂直度\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"3\",\"unit\":\"mm\"},{\"min_value\":\"0\",\"max_value\":\"8\",\"conditions\":\"[0,8]\",\"measurement_item_name\":\"平整度\",\"quality_algorithm\":\"RawValue\",\"mapped_sdk_item_id\":\"2\",\"unit\":\"mm\"},{\"min_value2\":\"-5\",\"max_value2\":\"11\",\"conditions2\":\"[-5,11]\",\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"外门窗洞口尺寸宽度偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"5\",\"unit\":\"mm\"},{\"min_value2\":\"-5\",\"max_value2\":\"5\",\"conditions2\":\"[-5,5]\",\"min_value\":\"-10\",\"max_value\":\"10\",\"conditions\":\"[-10,10]\",\"measurement_item_name\":\"户内门洞尺寸宽度偏差\",\"quality_algorithm\":\"StandardDeviationWithDesignValue\",\"mapped_sdk_item_id\":\"11\",\"unit\":\"mm\"}],\"designs\":[{\"standard_value2\":\"5000\",\"standard_value\":\"3510\",\"name\":\"开间进深尺寸\",\"mapped_sdk_item_id\":\"21\"},{\"standard_value2\":\"1500\",\"standard_value\":\"880\",\"name\":\"门尺寸\",\"mapped_sdk_item_id\":\"11\"},{\"standard_value2\":\"800\",\"standard_value\":\"880\",\"name\":\"窗尺寸\",\"mapped_sdk_item_id\":\"5\"},{\"standard_value\":\"2810\",\"name\":\"净高\",\"mapped_sdk_item_id\":\"6\"}]}"
    }
  })
}

function getResult(id){
  return request({
    url: '/nuc/getResult',
    method: 'post',
    headers: {'Content-Type': 'application/json'},
    data: {
      "taskId": id
    }
  })
}

function getRules(){
  return request({
    url: '/nuc/getResult',
    method: 'post',
    headers: {'Content-Type': 'application/json'},
    data: {
      "taskId": '1'
    }
  })
}

export default {
    queryState,scan,queryAllFinishedTasks,queryDevicePowerAndSPace,submitRules,submitDesign,getResult,getRules,deleteTask


}
